import parole
from parole.colornames import colors
from parole.display import interpolateRGB
import pygame, random

import sim, main
from util import *

class Potion(sim.Potion):
    def __init__(self):
        sim.Potion.__init__(self, "farsight", "!", colors['Lime'])

    def quaff(self, quaffer):
        if quaffer is not main.player:
            parole.error('Nonplayer quaffed potion of farsight... cannot '
                         'handle this!')
            return
        main.mapFrame.bindVisibilityToFOV(None, 0)
        main.mapFrame.getMap().update()
        quaffer.farsight = True

        main.schedule.add(sim.Event('expire effect', main.schedule.time + 30000,
            (self,), dests=[self]))

    def listen(self, event):
        sim.Potion.listen(self, event)

        if event.id == 'expire effect' and event.args[0] is self:
            main.player.farsight = False
            main.player.bindMe()

#========================================
thingClass = Potion
